Repository navigation
Conversation
The ODF reader converts draw:transform rotate(r) to a DrawingML rot of 360 - r degrees and does not bring it into one turn. The writer turns rot back into rotate(-rot), so each open and save of an ODT, ODS or ODP file adds a whole turn to every rotated shape: rotate(-6.283185307179586), one turn, comes back as two. The shape looks the same, but the value grows on each save, and after about 98 saves the int rot overflows. Bring the angle into 0..360 degrees with fmod before it is written. Tested with OdpToPptxShape.RotationIsInOneTurn in test_odf: a slide with rotate(0.3), rotate(-6) and a whole turn, written in full and with 7 decimals. It fails without the fix. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Anton Oussik <antonoussik@gmail.com>
rot counts in 1/60000 of a degree, and the cast to int truncated the angle: rotate(0.3) is 342.81126614... degrees, 20568675.97 units, and was written as 20568675, almost a whole unit less. The angle can creep on each open of a saved file. Round to the nearest unit. A value that rounds up to 360 degrees is written as 0. Tested with OdpToPptxShape.RotationIsRounded in test_odf, on the same fixture: rotate(0.3) and rotate(-6) give 20568676 and 20626481, and the whole turn with 7 decimals, which rounds up to 360 degrees, gives 0. It fails without the fix. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Anton Oussik <antonoussik@gmail.com>
chrip
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
Approve. Looks good from my side. The build and test checks have not run on this commit yet, so merge once they pass.
The fix in OdfFile/Reader/Converter/oox_drawing.cpp:893-895 is correct: serialize_xfrm is shared by the document, spreadsheet and presentation converters, so one change covers all three. I recalculated the four fixture angles by hand. The old code gives 20568675, 42226480, 43200000 and 43199999, the new code gives 20568676, 20626481, 0 and 0, which is what the tests expect. I read the tests and the fixture but did not build or run them.
praise: The fixture is four hand-written shapes in a 1.4 kB file, and each one covers a different case (rounding, a negative angle, an exact whole turn, a value that rounds up to 360 degrees). That makes the tests easy to check.
Assisted-by: ClaudeCode:claude-fable-5-2
|
Could someone give this build a poke please? :-) |
Signed-off-by: Anton Oussik <antonoussik@gmail.com>
Head branch was pushed to by a user without write access
Signed-off-by: Anton Oussik <antonoussik@gmail.com>
|
Merged tree still passes |
Every open and save of an ODP, ODT, or an ODS adds a whole turn to each rotated shape. After 99 saves the int overflows, after which every rotated shape jumps to about 151 degrees rotation, and no error is shown.
Separately, the cast truncates instead of rounding, so each save can lose up to 1/60000 of a degree, always in the same direction, which adds up over many saves.
This fix normalises rotations to be bounded between 0 and 360 degrees, and rounds the values instead of simply truncating them.
Added two tests that run over a fixture with four rotated shapes. The tests:
Both tests fail on main, all 288 test_odf tests pass, and the conversion test output is unchanged.
Did some manual testing of this on my dev instance, saving and loading still works and produces no visible changes, or errors.
AI used extensively at every point in dev process, AI:
Human use limited to:
Assisted-by: ClaudeCode:claude-opus-5-5